package com.zhy.rpc.serializer;

import java.io.IOException;

/**
 * @author 随缘而愈
 * @version 1.0
 * @description 序列化接口
 * @date 24/2/2024 下午4:10
 */

public interface Serializer {

    /**
     * 序列化
     *
     * @param object 需要序列化对象
     * @throws  IOException
     * @return byte[]
     */
    <T> byte[] serialize (T object) throws IOException;

    /**
     * 反序列化
     *
     * @param bytes
     * @param type
     * @param <T>
     * @return
     * @throws IOException
     */
    <T> T deserialize(byte[] bytes, Class<T> type) throws IOException;
}
